\cleardoublepage{}
\begin{center}
  \bfseries \zihao{3} 摘要
\end{center}

在当前通讯技术的进步下，重型应用程序往往采取云端化的措施来减小对于服务请求终端的性能要求，并借此增大服务器计算资源的利用率。常见的应用场景有云桌面、云游戏、云端渲染等。但此类云端应用可能会需要利用到与客户端之间频繁的数据交换，Web 端使用的 HTTP 协议由于设计缺陷并不适用于这样的场景，使用 WebSocket 协议会是更好的选择。

本文首先讨论了在 Windows 上基于 I/O 完成端口的一种异步 Socket 服务器实现思路，再设计了应用于 WebSocket 端点的配套基础设施，并在此基础上实现了提供异步 I/O 接口的 WebSocket 服务器。同时也提供了作为示例的 （安全） Socket 客户端以及相应的 WebSocket 客户端实现。

与广泛使用的开源 WebSocket 框架对比，本项目设计的服务器框架拥有易用性强、可定制性高、二进制文件体积小等优势，同时在性能上与常见的 WebSocket++ 和 Boost.Beast 框架接近，部分场景上要更为优秀。

项目附带了用作示例的简单 WebSocket 服务器和客户端实现。示例应用程序通过框架提供的接口自定义了 WebSocket 事件的回调函数，提供了相互通信和文件发送/保存等简单功能，可以用作在此框架上进行后续开发的参考。

\vspace{5mm}

\noindent \textbf{关键词:} \hspace{5mm}  应用层协议；WebSocket；I/O 完成端口；异步 I/O；服务器框架

\cleardoublepage{}
\begin{center}
  \bfseries \zihao{3} Abstract
\end{center}

With the progress of communication technology, heavy-duty applications often adopt cloud-based measures to reduce the performance requirements for service request terminals and thereby increase the utilization of server computing resources. Common such application scenarios include cloud desktops, cloud games and cloud rendering, etc. However, such applications may need frequent data exchange with the client. The HTTP protocol used by web applications is not suitable for such scenarios due to ``design flaws''. So using the WebSocket protocol is a better choice here.

This article first discusses the implementation of an asynchronous socket server based on the I/O completion port API on Windows, and then designs the supporting infrastructure for WebSocket endpoints. On this basis, it implements a WebSocket server that provides asynchronous I/O interfaces. The (secure) Socket client and corresponding WebSocket client implementation are also provided as examples.

Compared with the widely used open source WebSocket implementations, the framework designed by this project has the advantages of strong ease of use, high customization, small binary file size, etc. At the same time, its performance is close to the common frameworks like WebSocket++ and Boost.Beast, even more excellent in some scenarios.

The project comes with a simple WebSocket server and client implementation used as examples. The example application customizes the callback function of the WebSocket event through the interface provided by the framework, provides simple functions such as mutual communication and file sending/saving, and can be used as a reference for subsequent development on this framework.

\vspace{5mm}

\noindent \textbf{Keywords:} \hspace{5mm}  Application layer protocol；WebSocket；I/O Completion Port；Asynchronous I/O；Server framework